package exttable.login;

import exttable.SGTTestParametrs;
import utils.ELocale;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: Apr 9, 2010
 * Time: 10:44:18 PM
 * To change this template use File | Settings | File Templates.
 */
public class LoginButtons implements ActionListener {

    JButton button;
    Locale locale;
    ELocale currentLocale;

    public LoginButtons(String lang, String localeName, ELocale currentLocale) {
        locale = new Locale(localeName);
        button = new JButton(lang);
        this.currentLocale = currentLocale;
        button.addActionListener(this);
    }

    public JButton getButton() {
        return button;

    }

    @Override
    public void actionPerformed(ActionEvent e) {
        SGTTestParametrs.getInstance().setLocale(locale);
        SGTTestParametrs.getInstance().setCurrentLocal(currentLocale);
        StartPanel.getInstance().frame.getContentPane().removeAll();
        StartPanel.getInstance().frame.dispose();
        StartPanel.getInstance().init();
        StartPanel.getInstance().frame.getContentPane().repaint();
        StartPanel.getInstance().frame.getContentPane().validate();
    }
}
